---
category: String
contributors:
    - mahdiyar
created: '2020-05-07'
title: Check if two strings are anagram
updated: '2021-10-13'
---

**JavaScript version**

```js areAnagram.js
const areAnagram = (str1, str2) =>
    str1.toLowerCase().split('').sort().join('') === str2.toLowerCase().split('').sort().join('');
```

**TypeScript version**

```ts areAnagram.ts
const areAnagram = (str1: string, str2: string): boolean =>
    str1.toLowerCase().split('').sort().join('') === str2.toLowerCase().split('').sort().join('');
```

**Examples**

```js examples.js
areAnagram('listen', 'silent'); // true
areAnagram('they see', 'the eyes'); // true
areAnagram('node', 'deno'); // true
```
